Adding a variable

Variables can be added only after a category is already added. All the variables located in the list after the category, are considered belonging to this category. Variables’ names must be unique within the whole list, and not within a category

There are several ways to add a variable to the list:

frxReport1.Variables['My Variable 1'] := 10;

this way adds a variable (if it does not exist already) or modifies a value of the existing variable.

var

Variable: TfrxVariable;

Variable := frxReport1.Variables.Add;

Variable.Name := 'My Variable 1';

Variable.Value := 10;

Both of the ways add a variable to the end of the list, therefore, it would be added to the last category. If a variable is supposed to be added to a specified position of the list, use the “Insert” method:

var

Variable: TfrxVariable;

Variable := frxReport1.Variables.Insert(1);

Variable.Name := 'My Variable 1';

Variable.Value := 10;

If a variable is to be added to the specified category, use the “AddVariable” method:

frxReport1.Variables.AddVariable('My Category 1', 'My Variable 2', 10);